import { ObjCreate } from "../../common/ObjCreate";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { GTextInput } from "../../../../../com/mui/controls/GTextInput";
type int = number;
//class NumberSetStepper
    
    export  class NumberSetStepper /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.createChildren();
            this.addListeners();
            return;
        }

        public get min(): int
        {
            return this._min;
        }

        public set min(arg1: int)
        {
            this._min = arg1;
            return;
        }

        public get max(): int
        {
            return this._max;
        }

        public set max(arg1: int)
        {
            this._max = arg1;
            return;
        }

        public get value(): int
        {
            return this._value;
        }

        public set value(arg1: int)
        {
            if (arg1 < this.min) 
            {
                this._value = this.min;
            }
            else if (arg1 > this.max) 
            {
                this._value = this.max;
            }
            else 
            {
                this._value = arg1;
            }
            this._numberInput.text = this._value.toString();
            return;
        }

        /* internal  */createChildren(): void
        {
            this._subBtn = ObjCreate.createGButton("", 0, 0, 18, 18, this, "SubBtn");
            this._numberInput = ObjCreate.createGTextInput(18, 0, 35, 18, this);
            this._numberInput.restrict = "0-9";
            this._addBtn = ObjCreate.createGButton("", 53, 0, 18, 18, this, "AddBtn");
            return;
        }

        /* internal  */addListeners(): void
        {
            this._subBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onButtonClick);
            this._addBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onButtonClick);
            this._numberInput.addEventListener(flash.events.Event.CHANGE, this.onChangeHandler);
            return;
        }

        /* internal  */onButtonClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=arg1.target;
            switch (loc1) 
            {
                case this._subBtn:
                {
                    --this.value;
                    break;
                }
                case this._addBtn:
                {
                    this.value = this.value + 1;
                    break;
                }
            }
            return;
        }

        /* internal  */onChangeHandler(arg1: Object /* flash.events.Event */): void
        {
            this.value = parseInt(this._numberInput.text);
            return;
        }

        /* internal */ /* var */_value: int;

        /* internal */ /* var */_max: int;

        /* internal */ /* var */_min: int;

        /* internal */ /* var */_subBtn: GButton;

        /* internal */ /* var */_addBtn: GButton;

        /* internal */ /* var */_numberInput: GTextInput;
    }
